<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Title</title>
    <script src="../js/vue.js"></script>
</head>

<body>
    <!-- 作用域：变量在某个范围内可用
        var 的缺陷：没有块级作用域

     -->
    <div id="app">
        {{message}}
    </div>
    <button>按钮1</button>
    <button>按钮2</button>
    <button>按钮3</button>
    <button>按钮4</button>
    <button>按钮5</button>

    <script>
        let btns = document.getElementsByTagName("button");

        //let声明
        for (let i = 0; i < btns.length; i++) {
            btns[i].addEventListener('click', function() {
                console.log('let声明：第' + (i + 1) + "个按钮被点击了");
            })
        }
        //var声明
        for (var i = 0; i < btns.length; i++) {
            btns[i].addEventListener('click', function() {
                console.log('var声明：第' + i + "个按钮被点击了");
            })
        }
    </script>
    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                message: '我是你爹!'
            },
            methods: {}
        });
    </script>
</body>

</html>